package com.dataseek.iot.core.enums;

/**
 * @author cc
 * @Title: 设备状态
 * @Description: 设备状态
 * @date 2021/10/243:28 下午
 * @since 1.0
 */
public enum DeviceSate {
    ONLINE("0", "在线"),
    OFFLINE("-1", "离线"),
    ALARM("1", "报警");

    private String code;

    private String name;

    DeviceSate(String code, String name){
        this.code = code;
        this.name  = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public static String getTextByCode(String code){
        //values() 会获取定义的 enum对象
        for(DeviceSate state : values()){
            if(state.getCode().equals(code)){
                return state.getName();
            }
        }
        return null;
    }
}
